import os

from function.data_deal import compar_rr, compar_hr
from function.fun_data_deal import df_get
from show.img_show import hr_boxpolt, rr_boxpolt

deal_path=r'D:\学习&科研\华为手表项目\华为数据\deal'
subject_path = r'D:\学习&科研\华为手表项目\华为数据\subject'
save_dir=r'D:\学习&科研\华为手表项目\华为数据统计和分析'
step = 40


def box_compare(save_dir,step):
    hr_result_dir = save_dir + '\\' + str(step) + 's\\compare_hr\\'
    rr_result_dir = save_dir + '\\' + str(step) + 's\\compare_rr\\'
    if not os.path.exists(hr_result_dir):
        os.makedirs(hr_result_dir)
        os.makedirs(rr_result_dir)
    for i in range(1004,1010):
        if i in [1063, ]:
            pass
        else:
            person=str(i)
            test=person+'-1-1'
            print(test)

            ecg_df,rrdata_df,ppg_df,rri_df,singlework_df,singledetail_df=df_get(deal_path, person, test)
            compar_rr_result = compar_rr(ecg_df, rrdata_df, rri_df,step)
            compar_rr_result.to_csv(rr_result_dir+ test + 'compare_rr.csv', index=False)

            compar_hr_result = compar_hr(ecg_df, rrdata_df, singledetail_df,step)
            compar_hr_result.to_csv(hr_result_dir+ test + 'compare_hr.csv', index=False)
    hr_boxpolt(hr_result_dir,save_dir,step)
    rr_boxpolt(rr_result_dir,save_dir,step)